<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-tabs type="border-card">
        <el-tab-pane label="简历投递">
          <!--简历投递-->
          <el-col :span="24">
            <el-card
              style="
                margin-top: 10px;
                padding-bottom: 10px;
                width: 100%;"
              shadow="hover">
              <div>

                <!--简历投递向标题-->
                <div class="job-status__title">
                  简历投递
                  <span class="job-status__title__must">必填</span>
                </div>
                <!--简历投递标题-->
                <!--简历投递列表展示-->
                <div style="clear: both;">
                  <el-card
                    style="
                    margin-top: 10px;
                    padding-bottom: 10px;
                    box-shadow: 1px 2px 5px #8c939d;
                    width: 100%;"
                    shadow="hover">
                    <template v-if="sendList.length != 0">
                      <el-descriptions v-for="(item,index) in sendList"  :key="item.id"  style="padding: 20px;color: red;"  :title="item.companyName" :column="2">
                        <template slot="extra">
                          <template v-if="item.statu === 1">

                          </template>
                          <template v-else-if="item.statu === 2">
                            <el-button type="success" size="mini" @click="handleConfirm(item)" class="el-icon-message-solid">已收到邮件提醒相关事宜，并如约进行面试。</el-button>
                          </template>

                          <template v-else-if="item.statu === 3">
                            <el-button type="danger" size="mini" @click="handleDelete(item.id)" class="el-icon-delete-solid">删除</el-button>
                          </template>

                        </template>
                        <el-descriptions-item label="公司名称">{{item.companyName}}</el-descriptions-item>
                        <el-descriptions-item label="岗位名称">{{item.postName}}</el-descriptions-item>
                        <el-descriptions-item label="投递时间">{{item.sendTime}}</el-descriptions-item>
                        <el-descriptions-item label="投递状态">
                          <template v-if="item.status === 0">
                            <el-tag>等待公司查看</el-tag>
                          </template>
                          <template v-else-if="item.status === 1">
                            <el-tag type="success">公司已查看</el-tag>
                          </template>
                          <template v-else-if="item.status === 2">
                            <el-tag type="danger">符合该公司要求</el-tag>
                          </template>
                          <template v-else-if="item.status === 3">
                            <el-tag type="warning">不符合该公司要求</el-tag>
                          </template>
                        </el-descriptions-item>
                      </el-descriptions>
                      <!--分页组件-->
                      <el-pagination
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        :total="pagination.total"
                        :page-sizes="[10, 20, 50, 100]"
                        @current-change="handleCurrentChange"
                        @size-change="handleSizeChange"
                        layout="total,sizes, prev, pager, next, jumper">
                      </el-pagination>
                      <!--分页组件-->
                    </template>
                    <template v-else>
                      <el-result icon="info" title="新增信息提示" subTitle="当前还没有简历投递方面的说明哦！">
                        <template slot="extra">
                          <el-empty description="快去简历投递吧！"></el-empty>
                        </template>
                      </el-result>
                    </template>

                  </el-card>
                </div>
                <!--简历投递列表展示-->
              </div>

            </el-card>


          </el-col>
          <!--简历投递  -->
        </el-tab-pane>
        <el-tab-pane label="邮件提醒">
          <!--展示表格-->
          <el-table
            ref="multipleTable"
            :data="dataList2"
            tooltip-effect="dark"
            style="width: 100%"
            border>
            <el-table-column
              prop="stuName"
              label="学生姓名"
              width="120">
            </el-table-column>
            <el-table-column
              prop="email"
              label="学生邮箱"
              width="170">
            </el-table-column>
            <el-table-column
              prop="subject"
              label="学生标题"
              width="400">
            </el-table-column>
            <el-table-column
              prop="text"
              label="邮件内容">
            </el-table-column>
            <el-table-column
              prop="sentDate"
              label="发送日期"
              width="250">
            </el-table-column>

          </el-table>
          <!--展示表格-->

          <!--分页组件-->
          <el-pagination
            :current-page="pagination2.currentPage"
            :page-size="pagination2.pageSize"
            :total="pagination2.total"
            :page-sizes="[10, 20, 50, 100]"
            @current-change="handleCurrentChange2"
            @size-change="handleSizeChange2"
            layout="total,sizes, prev, pager, next, jumper">
          </el-pagination>
          <!--分页组件-->
        </el-tab-pane>

      </el-tabs>
    </el-row>
  </div>
</template>
<script>
    import {findStudentSend,deleteSend} from "@/api/send";
    import {updateStatus} from "@/api/pass";
    import {getStudentEmail} from "@/api/email";
export default {
  name: "index",
  data() {
    return {
      sendList:[],//简历投递数组
      pagination: {//分页数据模型数
        currentPage: 1,//当前页码
        pageSize:10,//每页显示的记录数
        total:0,//总记录数
        queryParams:{}//查询条件
      },
      pagination2: {//分页数据模型数
        currentPage: 1,//当前页码
        pageSize: 10,//每页显示的记录数
        total: 0,//总记录数
        queryParams: {}//查询条件
      },
      dataList2: [],//当前页要展示的分页列表数据
    }
  },
  created() {
    this.findPage()
    this.findPage2()
  },
  methods: {
    //处理删除的方法
    handleDelete(id) {
      //弹出删除对话框
      this.$confirm(` 是否删除您对该公司的投递记录?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteSend(id).then(res=>{
          this.$message({
            showClose: true,
            message: '恭喜你，操作成功',
            type: 'success',
            onClose: () => {
              this.handleCurrentChange(1)
            }
          });
        })
      }).catch(() => {
        // 点击取消后调用
        // 空着，防止报错
      });
    },
    //获取学生简历投递集合
    findPage(){
      console.log("======系统正在获取学生简历投递集合========")
      findStudentSend(this.pagination).then(res=>{
        this.sendList = res.data.rows;
        this.pagination.total = res.data.total;
      });
      console.log("======系统获取学生简历投递集合成功！！========")
    },
    //学生确认参加面试
    handleConfirm(item){
      this.$confirm(`请您详细阅读邮件内容后，再决定是否参加该公司面试，是则点击确定，逾期未确定的将视为放弃！`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let passDto = {}
        passDto.companyId = item.companyId
        passDto.studentId = item.studentId
        updateStatus(passDto).then(res=>{
          this.$message({
            showClose: true,
            message: '恭喜你，操作成功',
            type: 'success',
            onClose: () => {
              this.handleCurrentChange(1)
            }
          });
        })
      }).catch(() => {
        // 点击取消后调用
        // 空着，防止报错
      });

    },
    //改变每页显示的条数
    handleSizeChange(pageSize) {
      this.pagination.pageSize = pageSize
      this.findPage()
    },
    //切换页码
    handleCurrentChange(currentPage) {
      this.pagination.currentPage = currentPage;
      this.findPage()
    },
    //改变每页显示的条数
    handleSizeChange2(pageSize) {
      this.pagination.pageSize = pageSize
      this.findPage2()
    },
    handleCurrentChange2(currentPage) {
      this.pagination.currentPage = currentPage;
      this.findPage2()
    },
    //处理分页查询的方法
    findPage2() {
      getStudentEmail(this.pagination2).then(res=>{
        this.dataList2 = res.data.rows;
        this.pagination2.total = res.data.total;
      })
    },
  }
}
</script>

<style scoped>

.s-scrollbar {
  overflow: hidden;
  position: relative;
}

/*求职状态标题*/
.job-status__title {
  float: left;
  margin-bottom: 29px;
  font-size: 24px;
  color: #333;
  letter-spacing: 1.21px;
}
/*求职状态标题*/

/*求职状态必填标识项*/
.job-status__title__must {
  background: #ef7c67;
  border-radius: 2px;
  display: inline-block;
  width: 34px;
  height: 16px;
  font-size: 12px;
  text-align: center;
  line-height: 16px;
  color: #fff;
  vertical-align: 4px;
}
/*求职状态必填标识项*/

/*个人信息包裹容器*/
.profile-pre-wrapper {
  clear: both;
  position: relative;
  color: #333;
  padding-top: 20px;
}
/*个人信息包裹容器*/




</style>
